package dao;

import java.util.ArrayList;
import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;

import comment.HibernateSessionFactory;

import pojo.TblAdvertAddress;
import pojo.Tbldeftype;
import pojo.advert.TblAdvert;

public class CodeDao {
	public List<TblAdvert> findActiveAdvert(String hql){
		List<TblAdvert> tblAdvertList =new ArrayList();
		try{
			Session session = HibernateSessionFactory.getSession();
			Query hqlQuery = session.createQuery(hql);
			tblAdvertList = hqlQuery.list();
		}catch(Exception e){
			e.printStackTrace();
		}finally{
			HibernateSessionFactory.closeSession();
		}
		return tblAdvertList;
		
	}
	public List<TblAdvertAddress> findAdvertAddressByHql(String hql){
		List<TblAdvertAddress> tblAdvertAddressList =new ArrayList();
		try{
			Session session = HibernateSessionFactory.getSession();
			Query hqlQuery = session.createQuery(hql);
			tblAdvertAddressList = hqlQuery.list();
		}catch(Exception e){
			e.printStackTrace();
		}finally{
			HibernateSessionFactory.closeSession();
		}
		return tblAdvertAddressList;
		
	}
	public List<Tbldeftype> findDefCodeByHql(String hql){
		List<Tbldeftype> tbldeftypeList =new ArrayList();
		try{
			Session session = HibernateSessionFactory.getSession();
			Query hqlQuery = session.createQuery(hql);
			tbldeftypeList = hqlQuery.list();
		}catch(Exception e){
			e.printStackTrace();
		}finally{
			HibernateSessionFactory.closeSession();
		}
		return tbldeftypeList;
	}

}
